<template>
  <div>
    <el-form :model="ListSongForm" :rules="rules" ref="ListSongForm" label-width="100px" class="demo-ruleForm">
  

        <el-form-item label="歌曲" prop="songName">
            <el-input v-model="ListSongForm.songName"></el-input>
        </el-form-item>

        
        <el-form-item label="专辑" prop="album">
            <el-input v-model="ListSongForm.album"></el-input>
        </el-form-item>

        <el-form-item>
            <el-button type="primary" @click="submitForm()">确定</el-button>
            <el-button @click="resetForm('ListSongForm')">重置</el-button>
        </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
    data(){
        return{
            ListSongForm:{
                songName:'',
                album:'',
                songListId:''
            },
            rules: {
                id: [
                    { required: true, message: '请输入数字', trigger: 'blur' },
                    { min: 1, max: 600, message: '1-600之间', trigger: 'blur' }
                ],
            }
        }
    },
    computed:{
        ...mapState('song1',['SingerId']),
    },
    methods:{
        resetForm(formName) {
          this.$refs[formName].resetFields();
        },
        async submitForm(){
            console.log(this.ListSongForm)
            const res = await this.$axios.post("ListSong/AddListSong",this.ListSongForm)
            if(res.code == "200"){
                this.$router.push("/listsong")
                this.$message.success(res.msg)
            }
            else{
                this.$message.error(res.msg)
            }
        }
    },
    created(){
        this.ListSongForm.songListId = this.SingerId
    }
}
</script>

<style scoped>

</style>